package com.ymatou.iapi.delivery.testcase;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.delivery.parameter.BillNoItem;
import com.ymatou.iapi.delivery.parameter.VerifyBillNosBean;
import com.ymatou.iapi.delivery.parameter.resp.VerifyBillNoResult;
import com.ymatou.iapi.delivery.service.VerifyBillNosCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.model.BillnoRule;
import com.ymttest.database.model.BillnoRuleObservation;
import com.ymttest.database.model.BillnoRuleOffender;
import com.ymttest.database.sqlwapper.BillnoRuleWapper;
import com.ymttest.utils.TestDataManager;
/**
*批量校验物流面单号接口接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_verifyBillNos {
	private static VerifyBillNosBean verifybillnosBean;
	private static VerifyBillNosCall verifybillnosCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("批量校验物流面单号接口接口");
	}

	@Before
	public void caseUp() {
		verifybillnosBean = new VerifyBillNosBean();
		verifybillnosCall = new VerifyBillNosCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(verifybillnosCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_000() {

		Logger.start(true, "拦截模式下,批量校验成功--拦截");
		try {

			Ts_modifyObservationMode.callModifyObservationMode("", "", false);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_001() {
		Logger.start(true, "拦截模式下,批量校验成功--拦截");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule(null,
					null);

			rules = rules.stream()
					.filter(r -> r.getEnabled() && !r.getObservation_mode())
					.collect(Collectors.toList());

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo("222");

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo("222");

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			Logger.verifyIsNull(verifybillnosCall.getString("Message"),
					"校验Message");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(false, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				List<BillnoRuleOffender> list = new BillnoRuleWapper()
						.selectBilloffenderbyBizNo(expextItem.getBizNo());

				Logger.comment("校验billno_rule_offender面单号规则拦截记录表");

				Logger.verifyEquals(expextItem.getBillNo(), list.get(0)
						.getBill_no(), "校验面单号");
				Logger.verifyEquals(expextItem.getYmtExpressCode(), list.get(0)
						.getYmt_expresscode(), "校验物流公司内部编码");
				Logger.verifyEquals(expextItem.getSellerId(), list.get(0)
						.getSeller_id(), "校验买手id");
				Logger.verifyEquals(expextItem.getSource(), list.get(0)
						.getSource(), "校验发货来源");
				Logger.verifyEquals(expextItem.getBizNo(), list.get(0)
						.getBiz_no(), "校验业务号");
				Logger.verifyEquals(expextItem.getExpressName(), list.get(0)
						.getExpress_name(), "校验物流公司名称");
				Logger.verifyIsContains(true,
						list.get(0).getRegex_rules().replace("\\\\", "\\")
								.contains(billnoRule.getRegex_rule()),
						"校验面单号正则表达式规则");

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_002() {
		Logger.start(true, "拦截模式下,批量校验成功--校验通过");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule("Y062",
					null);

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo("TF12345678901");

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo("Ea123456789GB");

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			Logger.verifyIsNull(verifybillnosCall.getString("Message"),
					"校验Message");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(true, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				List<BillnoRuleOffender> list = new BillnoRuleWapper()
						.selectBilloffenderbyBizNo(expextItem.getBizNo());

				Logger.verifyEquals(null, list, "校验查询结果为null");

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_003() {
		Logger.start(true, "拦截模式下,批量校验成功--部分通过");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule("Y062",
					null);

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			if (billnoRule.getObservation_mode()) {

				Ts_modifyObservationMode.callModifyObservationMode(
						billnoRule.getYmt_expresscode(),
						billnoRule.getRegex_rule(), false);
			}

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo("TGGG");

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo("Cd123456789GB");

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			boolean isMatch = false;

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				if (i == 1)

					isMatch = true;

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(isMatch, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				//第一个校验不过
				expextItem = verifybillnosBean.getBillNoItems().get(0);

				List<BillnoRuleOffender> list = new BillnoRuleWapper()
						.selectBilloffenderbyBizNo(expextItem.getBizNo());

				Logger.comment("校验billno_rule_offender面单号规则拦截记录表");

				Logger.verifyEquals(expextItem.getBillNo(), list.get(0)
						.getBill_no(), "校验面单号");
				Logger.verifyEquals(expextItem.getYmtExpressCode(), list.get(0)
						.getYmt_expresscode(), "校验物流公司内部编码");
				Logger.verifyEquals(expextItem.getSellerId(), list.get(0)
						.getSeller_id(), "校验买手id");
				Logger.verifyEquals(expextItem.getSource(), list.get(0)
						.getSource(), "校验发货来源");
				Logger.verifyEquals(expextItem.getBizNo(), list.get(0)
						.getBiz_no(), "校验业务号");
				Logger.verifyEquals(expextItem.getExpressName(), list.get(0)
						.getExpress_name(), "校验物流公司名称");
				Logger.verifyIsContains(true,
						list.get(0).getRegex_rules().replace("\\\\", "\\")
								.contains(billnoRule.getRegex_rule()),
						"校验面单号正则表达式规则");

			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//观察者模式已经不用了
	public void Tc_verifyBillNos_004() {
		Logger.start(true, "观察者模式下,批量校验通过");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule("Y071",
					"^[R]{1}[A-Z]{1}[\\d]{9}[K]{1}[R]{1}$");

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			if (!billnoRule.getObservation_mode()) {

				Ts_modifyObservationMode.callModifyObservationMode(
						billnoRule.getYmt_expresscode(),
						billnoRule.getRegex_rule(), true);
			}

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));

			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo(String.format("RA%sKR",
					TestDataManager.getRandomIntNum(9)));

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo(String.format("RA%sKR",
					TestDataManager.getRandomIntNum(9)));

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			Logger.verifyIsNull(verifybillnosCall.getString("Message"),
					"校验Message");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(true, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				List<BillnoRuleObservation> list = new BillnoRuleWapper()
						.selectBillobservationbyBizNo(expextItem.getBizNo());

				Logger.comment("校验billno_rule_observation面单号规则观察记录表");

				Logger.verifyEquals(expextItem.getBillNo(), list.get(0)
						.getBill_no(), "校验面单号");
				Logger.verifyEquals(expextItem.getYmtExpressCode(), list.get(0)
						.getYmt_expresscode(), "校验物流公司内部编码");
				Logger.verifyEquals(expextItem.getSellerId(), list.get(0)
						.getSeller_id(), "校验买手id");
				Logger.verifyEquals(expextItem.getSource(), list.get(0)
						.getSource(), "校验发货来源");
				Logger.verifyEquals(expextItem.getBizNo(), list.get(0)
						.getBiz_no(), "校验业务号");
				Logger.verifyEquals(expextItem.getExpressName(), list.get(0)
						.getExpress_name(), "校验物流公司名称");
				Logger.verifyIsContains(true,
						list.get(0).getRegex_rules().replace("\\\\", "\\")
								.contains(billnoRule.getRegex_rule()),
						"校验面单号正则表达式规则");

				Logger.verifyIsContains(true, list.get(0).getIs_match(),
						"校验is_match");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//观察者模式已经不用了
	public void Tc_verifyBillNos_005() {
		Logger.start(true, "观察者模式下,批量校验不通过");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule("Y071",
					"^[R]{1}[A-Z]{1}[\\d]{9}[K]{1}[R]{1}$");

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			if (!billnoRule.getObservation_mode()) {

				Ts_modifyObservationMode.callModifyObservationMode(
						billnoRule.getYmt_expresscode(),
						billnoRule.getRegex_rule(), true);
			}

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));

			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo(String.format("%s",
					TestDataManager.getRandomIntNum(5)));

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo(String.format("%s",
					TestDataManager.getRandomIntNum(5)));

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(false, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				List<BillnoRuleObservation> list = new BillnoRuleWapper()
						.selectBillobservationbyBizNo(expextItem.getBizNo());

				Logger.comment("校验billno_rule_observation面单号规则观察记录表");

				Logger.verifyEquals(expextItem.getBillNo(), list.get(0)
						.getBill_no(), "校验面单号");
				Logger.verifyEquals(expextItem.getYmtExpressCode(), list.get(0)
						.getYmt_expresscode(), "校验物流公司内部编码");
				Logger.verifyEquals(expextItem.getSellerId(), list.get(0)
						.getSeller_id(), "校验买手id");
				Logger.verifyEquals(expextItem.getSource(), list.get(0)
						.getSource(), "校验发货来源");
				Logger.verifyEquals(expextItem.getBizNo(), list.get(0)
						.getBiz_no(), "校验业务号");
				Logger.verifyEquals(expextItem.getExpressName(), list.get(0)
						.getExpress_name(), "校验物流公司名称");
				Logger.verifyIsContains(true,
						list.get(0).getRegex_rules().replace("\\\\", "\\")
								.contains(billnoRule.getRegex_rule()),
						"校验面单号正则表达式规则");

				Logger.verifyIsContains(false, list.get(0).getIs_match(),
						"校验is_match");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	//观察者模式已经不用了
	public void Tc_verifyBillNos_006() {
		Logger.start(true, "观察者模式下,批量校验部分不通过");
		try {

			BillnoRuleWapper billnoRuleWapper = new BillnoRuleWapper();

			List<BillnoRule> rules = billnoRuleWapper.selectBillnoRule("Y071",
					"^[R]{1}[A-Z]{1}[\\d]{9}[K]{1}[R]{1}$");

			BillnoRule billnoRule = rules
					.get(new Random().nextInt(rules.size()));

			if (!billnoRule.getObservation_mode()) {

				Ts_modifyObservationMode.callModifyObservationMode(
						billnoRule.getYmt_expresscode(),
						billnoRule.getRegex_rule(), true);
			}

			Logger.info("getRegex_rule:" + billnoRule.getRegex_rule());

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item.setExpressName(billnoRule.getExpress_name());
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));

			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo(String.format("RA%sKR",
					TestDataManager.getRandomIntNum(5)));

			BillNoItem item2 = new BillNoItem();

			item2.setYmtExpressCode(billnoRule.getYmt_expresscode());
			item2.setExpressName(billnoRule.getExpress_name());
			item2.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item2.setSellerId(288484L);
			item2.setSource(1);
			item2.setBillNo(String.format("RA%sKR",
					TestDataManager.getRandomIntNum(9)));

			verifybillnosBean.setBillNoItems(Arrays.asList(item, item2));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"true", "校验IsSuccess");

			Logger.verifyIsNull(verifybillnosCall.getString("Message"),
					"校验Message");

			List<VerifyBillNoResult> result = verifybillnosCall
					.getVerifyBillNosResp().getVerifyBillNoResults();

			for (int i = 0; i < verifybillnosBean.getBillNoItems().size(); i++) {

				BillNoItem expextItem = verifybillnosBean.getBillNoItems().get(
						i);
				VerifyBillNoResult actualResult = result.get(i);

				Logger.verifyEquals(expextItem.getBillNo(),
						actualResult.getBillNo(), "校验BillNo");
				Logger.verifyEquals(expextItem.getBizNo(),
						actualResult.getBizNo(), "校验BizNo");
				Logger.verifyEquals(expextItem.getExpressName(),
						actualResult.getExpressName(), "校验ExpressName");
				Logger.verifyEquals(expextItem.getSellerId(),
						actualResult.getSellerId(), "校验SellerId");
				Logger.verifyEquals(expextItem.getYmtExpressCode(),
						actualResult.getYmtExpressCode(), "校验YmtExpressCode");

				Logger.verifyEquals(false, actualResult.isMatch(), "校验match");

				Thread.sleep(5000);

				List<BillnoRuleObservation> list = new BillnoRuleWapper()
						.selectBillobservationbyBizNo(expextItem.getBizNo());

				Logger.comment("校验billno_rule_observation面单号规则观察记录表");

				Logger.verifyEquals(expextItem.getBillNo(), list.get(0)
						.getBill_no(), "校验面单号");
				Logger.verifyEquals(expextItem.getYmtExpressCode(), list.get(0)
						.getYmt_expresscode(), "校验物流公司内部编码");
				Logger.verifyEquals(expextItem.getSellerId(), list.get(0)
						.getSeller_id(), "校验买手id");
				Logger.verifyEquals(expextItem.getSource(), list.get(0)
						.getSource(), "校验发货来源");
				Logger.verifyEquals(expextItem.getBizNo(), list.get(0)
						.getBiz_no(), "校验业务号");
				Logger.verifyEquals(expextItem.getExpressName(), list.get(0)
						.getExpress_name(), "校验物流公司名称");
				Logger.verifyIsContains(true,
						list.get(0).getRegex_rules().replace("\\\\", "\\")
								.contains(billnoRule.getRegex_rule()),
						"校验面单号正则表达式规则");

				boolean isMatch = true;

				if (i == 1)
					isMatch = false;
				Logger.verifyIsContains(isMatch, list.get(i).getIs_match(),
						"校验is_match");
			}

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_007() {
		Logger.start(true, "ymtExpressCode 为null");
		try {

			BillNoItem item = new BillNoItem();

			//item.setYmtExpressCode("");
			item.setExpressName("auto");
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo("222");

			verifybillnosBean.setBillNoItems(Arrays.asList(item));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"false", "校验IsSuccess");

			Logger.verifyEquals("ILLEGAL_ARGUMENT",
					verifybillnosCall.getString("errorCode"), "校验errorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_008() {
		Logger.start(true, "billNo 为null");
		try {

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode("sss");
			item.setExpressName("auto");
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			//item.setBillNo("222");

			verifybillnosBean.setBillNoItems(Arrays.asList(item));
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"false", "校验IsSuccess");

			Logger.verifyEquals("ILLEGAL_ARGUMENT",
					verifybillnosCall.getString("errorCode"), "校验errorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_009() {
		Logger.start(true, "BillNoItems 为null");
		try {

			BillNoItem item = new BillNoItem();

			item.setYmtExpressCode("sss");
			item.setExpressName("auto");
			item.setBizNo(String.format("Au%s",
					TestDataManager.getRandomIntNum(10)));
			item.setSellerId(288484L);
			item.setSource(1);
			item.setBillNo("222");

			verifybillnosBean.setBillNoItems(null);
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"false", "校验IsSuccess");

			Logger.verifyEquals("ILLEGAL_ARGUMENT",
					verifybillnosCall.getString("errorCode"), "校验errorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_verifyBillNos_010() {
		Logger.start(true, "BillNoItems size 为0");
		try {

			List<BillNoItem> list = new ArrayList<BillNoItem>();

			verifybillnosBean.setBillNoItems(list);
			verifybillnosCall.setData(verifybillnosBean);
			verifybillnosCall.callService();

			Logger.verifyEquals(verifybillnosCall.getString("IsSuccess"),
					"false", "校验IsSuccess");

			Logger.verifyEquals("ILLEGAL_ARGUMENT",
					verifybillnosCall.getString("errorCode"), "校验errorCode");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}